package cn.xinfei.xdecision.common.model.common.requestParam;

import cn.xinfei.xdecision.common.utils.exception.ApiException;
import cn.xinfei.xdecision.common.utils.exception.enums.ErrorCodeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors
public class UpdateFolderParam {

    @NotEmpty(message = "规则id不能为空!")
    @ApiModelProperty("规则id")
    private List<Long> ids;

    @NotNull(message = "文件夹id不能为空!")
    @ApiModelProperty("文件夹id")
    private Long folderId;

    public static boolean checkNotNull(UpdateFolderParam param) {
        if (param == null || param.ids == null || param.ids.isEmpty() || param.folderId == null) {
            throw new ApiException(ErrorCodeEnum.PARAMS_EXCEPTION.getCode(), "id或者文件夹id为空");
        }
        return true;
    }
}
